/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package magic_model;

import java.util.ArrayList;
import java.util.Collections;

/**
 *
 * @author Tobias
 */
public class Deck{


    ArrayList<Card> cards = new ArrayList<Card>();
    private String deckname="";
    // ArrayList<Card> main = new ArrayList<Card>();
    // ArrayList<Card> sideboard = new ArrayList<Card>();
   /* public Deck(String[] lines){
      this(lines,MagicFormat.Standard);
    }
    
    public Deck(String[] lines, MagicFormat format){
         int cardCount=0;
        for(int i=0;i<lines.length;i++){
            String line = lines[i];
           String[] temp = line.split(" ");
           
            int quantity=Integer.parseInt(temp[0]);
            String name=temp[1];
            boolean isMain=true;
            
              cardCount+=quantity;
              if(format==MagicFormat.Standard||format==MagicFormat.Legacy||format==MagicFormat.Modern){
                  if(cardCount>60){
                      isMain=false;
                  }
              }
            cards.add(new Card(quantity,name,isMain));
        }
        
         if(format==MagicFormat.Standard||format==MagicFormat.Legacy||format==MagicFormat.Modern){
              if(cardCount!=60 || cardCount!=75){
                  throw new DeckFormatExeptione("Deck has not the correct quantity of cards: "+cardCount);
              }
         }
    }*/
    
    public Deck(){
        
    }
    public void setName(String deckname){
        this.deckname=deckname;
    }
    public String getName(){
        return deckname;
    }
    
    
    public void addCard(Card card){
        cards.add(card);
    }
    
    public void sort(){
        Collections.sort(cards);
    }
    
    public ArrayList<Card> getCards(){
        return cards;
    }
    
    public int getDeckSize(){
        int size=0;
        for(Card c:cards){
            size+=c.getQuantity();
        }
        return size;
    }
    /*
    public void addCard(int quantity,String name, boolean isMain){
        cards.add(new Card(quantity, name,isMain));
    }
    
    public void addCard(int quantity,String name){
        cards.add(new Card(quantity, name));
    }*/
  @Override
    public String toString(){
        String s=deckname+"\n";
        for(Card c:cards){
            s+= c.getQuantity()+" "+c.getName()+"\n";
        }
        
        return s;
    }
    
    public boolean isEmpty(){
        return cards.isEmpty();
    }

}
